<?php

class ParamsWidget extends CWidget
{
    public $config;
    
    public $values;
    
    public function getConfig()
    {
        return require(Yii::getPathOfAlias($this->config).'.php');
    }
    
    public function run()
    {
        $elements = $this->getConfig();
        $names = array_keys($elements['elements']);
        
        $__model = new Params();
        
        if (count($names)) {
            foreach ($names as $name) {
                $__model->$name = $this->values[$name];
            }
        }

        $__form = new CForm($this->config, $__model);     
        $__form->renderBegin(); 
        echo $__form->renderBody();
        $__form->renderEnd();
    }
}
